﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using MINERP.DAL.Statistics;

namespace MINERP.Statistics
{
    public partial class FrmPrintMJ : Form
    {
        public FrmPrintMJ()
        {
            InitializeComponent();
        }

        private void FrmPrintMJ_Load(object sender, EventArgs e)
        {
            //report1.Preview = previewControl1;
            //report1.Load(Application.StartupPath + "\\每日出片统计.frx");
            //previewControl1.Refresh();
            //previewControl1.Show();
            //report1.Show();
            dateEdit1.DateTime = DateTime.Now;
            dateEdit2.DateTime = DateTime.Now;

        }

        private void simpleButton1_Click(object sender, EventArgs e)
        {
            simpleButton1.Enabled = false;
            this.Cursor = Cursors.WaitCursor;
            int statType = 10;
            if (comboBoxEdit2.Text=="日")
            {
                statType = 10;
            }
            else if (comboBoxEdit2.Text == "月")
            {
                statType = 7;
            }
            else if (comboBoxEdit2.Text == "年")
            {
                statType = 4;
            }

            DataSet dsResult = OpenOrderAreaDAL.GetAreas(dateEdit1.DateTime.Date, dateEdit2.DateTime.Date.AddDays(1), statType);

            dsResult.WriteXml(@"C:\Windows\xmldata\每日出片统计.xml", XmlWriteMode.WriteSchema);


            // report1.RegisterData(dsResult);
            report1.Preview = previewControl1;
            report1.Load(Application.StartupPath + "\\每日出片统计.frx");
            previewControl1.Refresh();
            report1.SetParameterValue("startTime", dateEdit1.DateTime.Date);
            report1.SetParameterValue("endTime", dateEdit2.DateTime.Date);
            previewControl1.Show();
            report1.Show();
            this.Cursor = Cursors.Default;
            //simpleButton2.Visible = true;
            simpleButton1.Enabled = true;
        }

        private void simpleButton2_Click(object sender, EventArgs e)
        {

            report1.Preview = previewControl1;
            report1.Load(Application.StartupPath + "\\每日出片统计（柱状图）.frx");
            previewControl1.Refresh();
            previewControl1.Show();
            report1.Show();
        }
    }
}
